﻿<UserControl x:Class="RibbonWindowSample.UserControlWord"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ribbon="http://schemas.microsoft.com/winfx/2006/xaml/presentation/ribbon"
    xmlns:shell="http://schemas.microsoft.com/winfx/2006/xaml/presentation/shell"
    xmlns:data="clr-namespace:RibbonWindowSample.ViewModel"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:local="clr-namespace:RibbonWindowSample"
    Loaded="UserControl_Loaded"
    Unloaded="UserControl_Unloaded">
    <Grid>
        <Grid.Resources>

            <!-- RibbonControl -->
            <Style x:Key="RibbonControlStyle">
                <Setter Property="ribbon:RibbonControlService.Label" Value="{Binding Label}" />
                <Setter Property="ribbon:RibbonControlService.LargeImageSource" Value="{Binding LargeImage}" />
                <Setter Property="ribbon:RibbonControlService.SmallImageSource" Value="{Binding SmallImage}" />
                <Setter Property="ribbon:RibbonControlService.ToolTipTitle" Value="{Binding ToolTipTitle}" />
                <Setter Property="ribbon:RibbonControlService.ToolTipDescription" Value="{Binding ToolTipDescription}" />
                <Setter Property="ribbon:RibbonControlService.ToolTipImageSource" Value="{Binding ToolTipImage}" />
                <Setter Property="ribbon:RibbonControlService.ToolTipFooterTitle" Value="{Binding ToolTipFooterTitle}" />
                <Setter Property="ribbon:RibbonControlService.ToolTipFooterDescription" Value="{Binding ToolTipFooterDescription}" />
                <Setter Property="ribbon:RibbonControlService.ToolTipFooterImageSource" Value="{Binding ToolTipFooterImage}" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding LargeImage}" Value="{x:Null}">
                        <Setter Property="ribbon:RibbonControlService.LargeImageSource" Value="{x:Null}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding SmallImage}" Value="{x:Null}">
                        <Setter Property="ribbon:RibbonControlService.SmallImageSource" Value="{x:Null}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding ToolTipImage}" Value="{x:Null}">
                        <Setter Property="ribbon:RibbonControlService.ToolTipImageSource" Value="{x:Null}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding ToolTipFooterImage}" Value="{x:Null}">
                        <Setter Property="ribbon:RibbonControlService.ToolTipFooterImageSource" Value="{x:Null}" />
                    </DataTrigger>
                    <Trigger Property="ribbon:RibbonControlService.IsInQuickAccessToolBar" Value="False">
                        <Setter Property="KeyTipService.KeyTip" Value="{Binding KeyTip}" />
                    </Trigger>
                </Style.Triggers>
            </Style>

            <!-- RibbonGroup -->
            <Style TargetType="{x:Type ribbon:RibbonGroup}"  BasedOn="{StaticResource RibbonControlStyle}">
                <Setter Property="QuickAccessToolBarId" Value="{Binding Label}" />
                <Setter Property="Header" Value="{Binding Label}" />
            </Style>

            <!-- RibbonButton -->
            <Style TargetType="{x:Type ribbon:RibbonButton}" BasedOn="{StaticResource RibbonControlStyle}">
                <Setter Property="Command" Value="{Binding Command}" />
            </Style>

            <!-- RibbonToggleButton -->
            <Style TargetType="{x:Type ribbon:RibbonToggleButton}" BasedOn="{StaticResource RibbonControlStyle}">
                <Setter Property="Command" Value="{Binding Command}" />
                <Setter Property="IsChecked" Value="{Binding IsChecked}" />
            </Style>

            <!-- RibbonRadioButton -->
            <Style TargetType="{x:Type ribbon:RibbonRadioButton}" BasedOn="{StaticResource RibbonControlStyle}">
                <Setter Property="Command" Value="{Binding Command}" />
                <Setter Property="IsChecked" Value="{Binding IsChecked}" />
            </Style>

            <!-- RibbonCheckBox -->
            <Style TargetType="{x:Type ribbon:RibbonCheckBox}" BasedOn="{StaticResource RibbonControlStyle}">
                <Setter Property="Command" Value="{Binding Command}" />
                <Setter Property="IsChecked" Value="{Binding IsChecked}" />
            </Style>

            <!-- RibbonTextBox -->
            <Style TargetType="{x:Type ribbon:RibbonTextBox}" BasedOn="{StaticResource RibbonControlStyle}">
                <Setter Property="Command" Value="{Binding Command}" />
                <Setter Property="Text" Value="{Binding Text}" />
            </Style>

            <!-- RibbonMenuButton -->
            <Style TargetType="{x:Type ribbon:RibbonMenuButton}" BasedOn="{StaticResource RibbonControlStyle}">
                <Setter Property="QuickAccessToolBarId" Value="{Binding Command}" />
                <Setter Property="CanUserResizeVertically" Value="{Binding IsVerticallyResizable}" />
                <Setter Property="CanUserResizeHorizontally" Value="{Binding IsHorizontallyResizable}" />
            </Style>

            <!-- RibbonSplitButton -->
            <Style TargetType="{x:Type ribbon:RibbonSplitButton}" BasedOn="{StaticResource {x:Type ribbon:RibbonMenuButton}}">
                <Setter Property="IsCheckable" Value="{Binding IsCheckable}" />
                <Setter Property="IsChecked" Value="{Binding IsChecked}" />
                <Setter Property="Command" Value="{Binding Command}" />
                <Setter Property="HeaderQuickAccessToolBarId" Value="{Binding Label}" />
                <Setter Property="DropDownToolTipTitle" Value="{Binding DropDownButtonData.ToolTipTitle}" />
                <Setter Property="DropDownToolTipDescription" Value="{Binding DropDownButtonData.ToolTipDescription}" />
                <Setter Property="DropDownToolTipImageSource" Value="{Binding DropDownButtonData.ToolTipImage}" />
                <Setter Property="DropDownToolTipFooterTitle" Value="{Binding DropDownButtonData.ToolTipFooterTitle}" />
                <Setter Property="DropDownToolTipFooterDescription" Value="{Binding DropDownButtonData.ToolTipFooterDescription}" />
                <Setter Property="DropDownToolTipFooterImageSource" Value="{Binding DropDownButtonData.ToolTipFooterImage}" />
            </Style>

            <!-- RibbonComboBox -->
            <Style TargetType="{x:Type ribbon:RibbonComboBox}" BasedOn="{StaticResource {x:Type ribbon:RibbonMenuButton}}">
                <Setter Property="IsEditable" Value="True" />
                <Setter Property="CanUserResizeVertically" Value="True" />
            </Style>
            
            <!-- RibbonGallery FilterItemContainerStyle -->
            <Style TargetType="{x:Type ribbon:RibbonMenuItem}" x:Key="FilterMenuItemStyle">
                <Setter Property="Header" Value="{Binding Label}"/>
            </Style> 

            <!-- RibbonGallery -->
            <Style TargetType="{x:Type ribbon:RibbonGallery}">
                <Style.Resources>
                    <!-- Note that this Style has been specified only to trump the 
                         implicit style for RibbonMenuItem from being picked by the 
                         items within the FilterMenuButton -->
                    <Style TargetType="{x:Type ribbon:RibbonMenuItem}" />
                </Style.Resources>
                <Setter Property="ribbon:RibbonControlService.SmallImageSource" Value="{Binding SmallImage}" />
                <Setter Property="ItemsSource" Value="{Binding CategoryDataCollection}" />
                <Setter Property="Command" Value="{Binding Command}" />
                <Setter Property="SelectedItem" Value="{Binding SelectedItem}" />
                <Setter Property="CanUserFilter" Value="{Binding CanUserFilter}" />
                <Setter Property="FilterItemContainerStyle" Value="{StaticResource FilterMenuItemStyle}" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding SmallImage}" Value="{x:Null}">
                        <Setter Property="ribbon:RibbonControlService.SmallImageSource" Value="{x:Null}" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <!-- RibbonGalleryCategory -->
            <Style TargetType="{x:Type ribbon:RibbonGalleryCategory}">
                <Setter Property="Header" Value="{Binding Label}" />
                <Setter Property="ItemsSource" Value="{Binding GalleryItemDataCollection}" />
            </Style>

            <!-- RibbonMenuItem -->
            <Style TargetType="{x:Type ribbon:RibbonMenuItem}">
                <Setter Property="Header" Value="{Binding Label}" />
                <Setter Property="ImageSource" Value="{Binding SmallImage}" />
                <Setter Property="ribbon:RibbonControlService.ToolTipTitle" Value="{Binding ToolTipTitle}" />
                <Setter Property="ribbon:RibbonControlService.ToolTipDescription" Value="{Binding ToolTipDescription}" />
                <Setter Property="ribbon:RibbonControlService.ToolTipImageSource" Value="{Binding ToolTipImage}" />
                <Setter Property="ribbon:RibbonControlService.ToolTipFooterTitle" Value="{Binding ToolTipFooterTitle}" />
                <Setter Property="ribbon:RibbonControlService.ToolTipFooterDescription" Value="{Binding ToolTipFooterDescription}" />
                <Setter Property="ribbon:RibbonControlService.ToolTipFooterImageSource" Value="{Binding ToolTipFooterImage}" />
                <Setter Property="KeyTipService.KeyTip" Value="{Binding KeyTip}" />
                <Setter Property="Command" Value="{Binding Command}" />
                <Setter Property="IsCheckable" Value="{Binding IsCheckable}" />
                <Setter Property="IsChecked" Value="{Binding IsChecked}" />
                <Setter Property="CanUserResizeVertically" Value="{Binding IsVerticallyResizable}" />
                <Setter Property="CanUserResizeHorizontally" Value="{Binding IsHorizontallyResizable}" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding SmallImage}" Value="{x:Null}">
                        <Setter Property="ImageSource" Value="{x:Null}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding ToolTipImage}" Value="{x:Null}">
                        <Setter Property="ribbon:RibbonControlService.ToolTipImageSource" Value="{x:Null}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding ToolTipFooterImage}" Value="{x:Null}">
                        <Setter Property="ribbon:RibbonControlService.ToolTipFooterImageSource" Value="{x:Null}" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <!-- RibbonSplitMenuItem -->
            <Style TargetType="{x:Type ribbon:RibbonSplitMenuItem}" BasedOn="{StaticResource {x:Type ribbon:RibbonMenuItem}}">
                <Setter Property="HeaderQuickAccessToolBarId" Value="{Binding Command}" />
                <Setter Property="QuickAccessToolBarId" Value="{Binding DropDownButtonData.Command}" />
                <Setter Property="HeaderKeyTip" Value="{Binding KeyTip}" />
                <Setter Property="KeyTip" Value="{Binding DropDownButtonData.KeyTip}" />
                <Setter Property="DropDownToolTipTitle" Value="{Binding DropDownButtonData.ToolTipTitle}" />
                <Setter Property="DropDownToolTipDescription" Value="{Binding DropDownButtonData.ToolTipDescription}" />
                <Setter Property="DropDownToolTipImageSource" Value="{Binding DropDownButtonData.ToolTipImage}" />
                <Setter Property="DropDownToolTipFooterTitle" Value="{Binding DropDownButtonData.ToolTipFooterTitle}" />
                <Setter Property="DropDownToolTipFooterDescription" Value="{Binding DropDownButtonData.ToolTipFooterDescription}" />
                <Setter Property="DropDownToolTipFooterImageSource" Value="{Binding DropDownButtonData.ToolTipFooterImage}" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding DropDownButtonData.ToolTipImage}" Value="{x:Null}">
                        <Setter Property="DropDownToolTipImageSource" Value="{x:Null}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding DropDownButtonData.ToolTipFooterImage}" Value="{x:Null}">
                        <Setter Property="DropDownToolTipFooterImageSource" Value="{x:Null}" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <!-- RibbonApplicationMenuItem -->
            <Style TargetType="{x:Type ribbon:RibbonApplicationMenuItem}" BasedOn="{StaticResource {x:Type ribbon:RibbonMenuItem}}">
                <Style.Triggers>
                    <Trigger Property="Level" Value="Middle">
                        <Setter Property="ImageSource" Value="{Binding SmallImage}" />
                        <Setter Property="KeyTipService.KeyTip" Value="{Binding KeyTip}" />
                        <Setter Property="Command" Value="{Binding Command}" />
                        <Setter Property="Header" Value="{Binding}" />
                        <Setter Property="HeaderTemplate">
                            <Setter.Value>
                                <DataTemplate>
                                    <Grid>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                        </Grid.RowDefinitions>
                                        <AccessText Grid.Row="0" FontWeight="Bold" Text="{Binding Label}" />
                                        <TextBlock Grid.Row="1" Text="{Binding ToolTipTitle}" TextWrapping="Wrap" />
                                    </Grid>
                                </DataTemplate>
                            </Setter.Value>
                        </Setter>
                    </Trigger>
                </Style.Triggers>
            </Style>

            <!-- RibbonApplicationSplitMenuItem -->
            <Style TargetType="{x:Type ribbon:RibbonApplicationSplitMenuItem}" BasedOn="{StaticResource {x:Type ribbon:RibbonSplitMenuItem}}" />

            <!-- RibbonContextMenu -->
            <Style TargetType="{x:Type ribbon:RibbonContextMenu}">
                <Style.Resources>
                    <!-- Note that this Style has been specified only to trump the 
                         implicit style for RibbonMenuItem from being picked by the 
                         items within the ContextMenu -->
                    <Style TargetType="{x:Type ribbon:RibbonMenuItem}" />
                </Style.Resources>
            </Style>

            <!-- RibbonControlGroup -->
            <Style TargetType="{x:Type ribbon:RibbonControlGroup}">
                <Setter Property="Margin" Value="2,0,2,0" />
            </Style>

            <BooleanToVisibilityConverter x:Key="BoolToVisibilityConverter" />
            <!-- RibbonContextualTabGroup -->
            <Style TargetType="{x:Type ribbon:RibbonContextualTabGroup}">
                <Setter Property="Header" Value="{Binding Header}" />
                <Setter Property="Visibility" Value="{Binding IsVisible,Converter={StaticResource BoolToVisibilityConverter}}" />
            </Style>

            <!-- RibbonTab -->
            <Style TargetType="{x:Type ribbon:RibbonTab}" x:Key="ContextualTabStyle">
                <Setter Property="ContextualTabGroupHeader" Value="{Binding ContextualTabGroupHeader}" />
                <Setter Property="Header" Value="{Binding Header}" />
                <Setter Property="IsSelected" Value="{Binding IsSelected}" />
            </Style>


        </Grid.Resources>

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <ribbon:Ribbon x:Name="ribbon" HelpPaneContent="{x:Static data:WordModel.Help}">
            <ribbon:Ribbon.HelpPaneContentTemplate>
                <DataTemplate>
                    <ribbon:RibbonButton DataContext="{Binding}" />
                </DataTemplate>
            </ribbon:Ribbon.HelpPaneContentTemplate>
            
            <ribbon:Ribbon.ApplicationMenu>
                <ribbon:RibbonApplicationMenu SmallImageSource="Images\Document_16x16.png" KeyTip="F">
                    
                    <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.New}" />
                    <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.Open}" />
                    <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.Save}" />
                    
                    <ribbon:RibbonApplicationSplitMenuItem DataContext="{x:Static data:WordModel.SaveAs}">
                        <ribbon:RibbonApplicationSplitMenuItem.Resources>
                        </ribbon:RibbonApplicationSplitMenuItem.Resources>
                        <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.SaveAsWordDocument}" />
                        <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.SaveAsWordTemplate}" />
                        <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.SaveAsWord97To2003Document}" />
                        <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.SaveAsOpenDocumentText}" />
                        <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.SaveAsPdfOrXps}" />
                        <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.SaveAsOtherFormat}" />
                    </ribbon:RibbonApplicationSplitMenuItem>
                    
                    <ribbon:RibbonSeparator/>
                    
                    <ribbon:RibbonApplicationSplitMenuItem DataContext="{x:Static data:WordModel.Print}">
                        <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.PrintOptions}" />
                        <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.QuickPrint}" />
                        <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.PrintPreview}" />
                    </ribbon:RibbonApplicationSplitMenuItem>
                    
                    <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.Prepare}">
                        <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.Properties}" />
                        <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.InspectDocument}" />
                        <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.EncryptDocument}" />
                        <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.RestrictPermission}">
                            <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.UnrestrictedAccess}" />
                            <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.RestrictedAccess}" />
                            <ribbon:RibbonSeparator/>
                            <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.DoNotReplyAll}" />
                            <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.MicrosoftAllAllRights}" />
                            <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.MicrosoftAllAllRightsExceptCopyAndPrint}" />
                            <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.MicrosoftAllReadOnly}" />
                            <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.MicrosoftFteAllRightsExceptCopyAndPrint}" />
                            <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.MicrosoftFteReadOnly}" />
                            <ribbon:RibbonSeparator/>
                            <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.ManageCredentials}" />
                        </ribbon:RibbonApplicationMenuItem>
                        <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.AddADigitalSignature}" />
                        <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.MarkAsFinal}" />
                        <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.RunCompatibilityChecker}" />
                    </ribbon:RibbonApplicationMenuItem>
                    
                    <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.Send}">
                        <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.Email}" />
                        <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.EmailAsPdfAttachment}" />
                        <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.EmailAsXpsAttachment}" />
                        <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.InternetFax}" />
                    </ribbon:RibbonApplicationMenuItem>
                    
                    <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.Publish}">
                        <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.Blog}" />
                        <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.DocumentManagementServer}" />
                        <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:WordModel.CreateDocumentWorkspace}" />
                    </ribbon:RibbonApplicationMenuItem>
                    
                    <ribbon:RibbonSeparator/>
                    
                    <ribbon:RibbonApplicationMenuItem  Header="Wor_kflows" ImageSource="Images\Open_16x16.png" />
                    
                    <ribbon:RibbonSeparator/>
                    
                    <ribbon:RibbonApplicationMenuItem Header="_Close" ImageSource="Images\Open_16x16.png" />
                    
                    <ribbon:RibbonApplicationMenu.AuxiliaryPaneContent>
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="5" />
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>
                            <ribbon:RibbonSeparator Grid.Row="0" Label="Recent Documents"/>
                            <ItemsControl
                                Grid.Row="2" 
                                ItemsSource="{Binding Source={x:Static data:WordModel.RecentDocuments},Path=GalleryItemDataCollection}">
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                        <Border x:Name="MainBorder" 
                                                BorderThickness="1"
                                                Padding="5,2,5,2">
                                            <Grid>
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="Auto" />
                                                    <ColumnDefinition Width="5" />
                                                    <ColumnDefinition Width="*" />
                                                    <ColumnDefinition Width="Auto" />
                                                </Grid.ColumnDefinitions>
                                                <TextBlock Grid.Column="0" Text="{Binding Index}" TextDecorations="Underline" />
                                                <TextBlock Grid.Column="2" Text="{Binding Label}" />
                                                <Image x:Name="Pin" Grid.Column="3" Source="Images\EditUndo_16x16.png" />
                                                <Image x:Name="Unpin" Grid.Column="3" Source="Images\EditRedo_16x16.png" Visibility="Collapsed" />
                                            </Grid>
                                        </Border>
                                        <DataTemplate.Triggers>
                                            <DataTrigger Binding="{Binding IsChecked}" Value="True">
                                                <Setter TargetName="Pin" Property="Visibility" Value="Collapsed" />
                                                <Setter TargetName="Unpin" Property="Visibility" Value="Visible" />
                                            </DataTrigger>
                                            <Trigger Property="IsMouseOver" Value="True">
                                                <Setter TargetName="MainBorder" Property="Background" Value="{Binding RelativeSource={RelativeSource TemplatedParent},Path=(ribbon:RibbonControlService.Ribbon).MouseOverBackground}" />
                                                <Setter TargetName="MainBorder" Property="BorderBrush" Value="{Binding RelativeSource={RelativeSource TemplatedParent},Path=(ribbon:RibbonControlService.Ribbon).MouseOverBorderBrush}" />
                                            </Trigger> 
                                        </DataTemplate.Triggers>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                            </ItemsControl>
                        </Grid>
                    </ribbon:RibbonApplicationMenu.AuxiliaryPaneContent>
                    
                    <ribbon:RibbonApplicationMenu.FooterPaneContent>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <ribbon:RibbonButton Grid.Column="1" DataContext="{x:Static data:WordModel.WordOptions}"/>
                            <ribbon:RibbonButton Grid.Column="2" DataContext="{x:Static data:WordModel.ExitWord}" />
                        </Grid>
                    </ribbon:RibbonApplicationMenu.FooterPaneContent>
                    
                </ribbon:RibbonApplicationMenu>
            </ribbon:Ribbon.ApplicationMenu>

            <ribbon:RibbonTab Header="Home" KeyTip="H" GroupSizeReductionOrder="Paragraph, Font, Editing, Paragraph, Clipboard">

                <ribbon:RibbonGroup x:Name="Clipboard" DataContext="{x:Static data:WordModel.Clipboard}">

                    <ribbon:RibbonSplitButton DataContext="{x:Static data:WordModel.Paste}">
                        <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.Paste}" />
                        <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.PasteSpecial}" />
                        <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.PasteAsHyperlink}" />
                    </ribbon:RibbonSplitButton>

                    <ribbon:RibbonButton DataContext="{x:Static data:WordModel.Cut}" />
                    <ribbon:RibbonButton DataContext="{x:Static data:WordModel.Copy}" />
                    <ribbon:RibbonButton DataContext="{x:Static data:WordModel.FormatPainter}" />

                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup x:Name="Font" DataContext="{x:Static data:WordModel.Font}">
                    <ribbon:RibbonGroup.Resources>
                        <DataTemplate x:Key="FontControlTemplate">
                            <Grid VerticalAlignment="Center">
                                <Grid.RowDefinitions>
                                    <RowDefinition />
                                    <RowDefinition />
                                    <RowDefinition x:Name="ThirdRow" Height="Auto" />
                                </Grid.RowDefinitions>
                                <StackPanel x:Name="SP1"
                                            Grid.Row="0"
                                            VerticalAlignment="Center"
                                        Orientation="Horizontal">
                                    
                                    <ribbon:RibbonComboBox 
                                            DataContext="{x:Static data:WordModel.FontFace}"
                                            SelectionBoxWidth="110">
                                        <ribbon:RibbonGallery
                                                DataContext="{x:Static data:WordModel.FontFaceGallery}"
                                                MaxColumnCount="1" />
                                    </ribbon:RibbonComboBox>

                                    <ribbon:RibbonComboBox 
                                            DataContext="{x:Static data:WordModel.FontSize}"
                                            SelectionBoxWidth="25">
                                        <ribbon:RibbonGallery 
                                                DataContext="{x:Static data:WordModel.FontSizeGallery}"
                                                MaxColumnCount="1">
                                            <ribbon:RibbonGallery.CategoryStyle>
                                                <Style TargetType="{x:Type ribbon:RibbonGalleryCategory}" BasedOn="{StaticResource {x:Type ribbon:RibbonGalleryCategory}}">
                                                    <Setter Property="HeaderVisibility" Value="Collapsed" />
                                                </Style>
                                            </ribbon:RibbonGallery.CategoryStyle>
                                        </ribbon:RibbonGallery>
                                    </ribbon:RibbonComboBox>
                                    
                                    <ContentControl x:Name="CC1" Focusable="False">
                                        <ribbon:RibbonControlGroup x:Name="RCG1">
                                            <ribbon:RibbonButton DataContext="{x:Static data:WordModel.GrowFont}" />
                                            <ribbon:RibbonButton DataContext="{x:Static data:WordModel.ShrinkFont}" />
                                        </ribbon:RibbonControlGroup>
                                    </ContentControl>
                                    <ContentControl x:Name="CC2" Focusable="False">
                                        <ribbon:RibbonControlGroup x:Name="RCG2">
                                            <ribbon:RibbonButton DataContext="{x:Static data:WordModel.ClearFormatting}" />
                                        </ribbon:RibbonControlGroup>
                                    </ContentControl>
                                </StackPanel>
                                <StackPanel x:Name="SP2" 
                                            Grid.Row="1"
                                            VerticalAlignment="Center"
                                            Orientation="Horizontal"
                                            Margin="0,5,0,0">
                                    <ribbon:RibbonControlGroup>

                                        <ribbon:RibbonToggleButton DataContext="{x:Static data:WordModel.Bold}" />
                                        <ribbon:RibbonToggleButton DataContext="{x:Static data:WordModel.Italic}" />

                                        <ribbon:RibbonSplitButton DataContext="{x:Static data:WordModel.Underline}">
                                            <ribbon:RibbonGallery DataContext="{x:Static data:WordModel.UnderlineGallery}">
                                                <ribbon:RibbonGallery.CategoryStyle>
                                                    <Style 
                                                            TargetType="{x:Type ribbon:RibbonGalleryCategory}" 
                                                            BasedOn="{StaticResource {x:Type ribbon:RibbonGalleryCategory}}">
                                                        <Setter Property="MinColumnCount" Value="1" />
                                                        <Setter Property="MaxColumnCount" Value="1" />
                                                        <Setter Property="HeaderVisibility" Value="Collapsed" />
                                                    </Style>
                                                </ribbon:RibbonGallery.CategoryStyle>
                                            </ribbon:RibbonGallery>
                                            <ribbon:RibbonMenuItem 
                                                    DataContext="{x:Static data:WordModel.MoreUnderlines}" 
                                                    ImageSource="{x:Null}" 
                                                    QuickAccessToolBarImageSource="{Binding SmallImage}" />
                                            <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.FontColor}" Header="_Underline Color">
                                                <ribbon:RibbonGallery
                                                        DataContext="{x:Static data:WordModel.FontColorGallery}"
                                                        x:Name="UnderlineColorGallery"
                                                        ScrollViewer.VerticalScrollBarVisibility="Hidden">
                                                    <ribbon:RibbonGallery.CategoryStyle>
                                                        <Style 
                                                            TargetType="{x:Type ribbon:RibbonGalleryCategory}" 
                                                            BasedOn="{StaticResource {x:Type ribbon:RibbonGalleryCategory}}">
                                                            <Setter Property="MinColumnCount" Value="10" />
                                                            <Setter Property="MaxColumnCount" Value="10" />
                                                            <Style.Triggers>
                                                                <Trigger Property="Header" Value="Automatic Color">
                                                                    <Setter Property="HeaderVisibility" Value="Collapsed" />
                                                                    <Setter Property="MinColumnCount" Value="1" />
                                                                    <Setter Property="MaxColumnCount" Value="1" />
                                                                    <Setter Property="IsSharedColumnSizeScope" Value="True" />
                                                                </Trigger>
                                                            </Style.Triggers>
                                                        </Style>
                                                    </ribbon:RibbonGallery.CategoryStyle>
                                                    <ribbon:RibbonGallery.GalleryItemTemplate>
                                                        <DataTemplate>
                                                            <Grid>
                                                                <Rectangle x:Name="Rect" Width="16" Height="16" Fill="{Binding}" />
                                                                <Grid x:Name="AutomaticColorPane"
                                                                      Width="210"
                                                                      Visibility="Collapsed">
                                                                    <Grid.ColumnDefinitions>
                                                                        <ColumnDefinition Width="Auto" />
                                                                        <ColumnDefinition Width="*" />
                                                                    </Grid.ColumnDefinitions>
                                                                    <Rectangle Width="16" Height="16" StrokeThickness="1" Stroke="Orange" Fill="{Binding}"/>
                                                                    <TextBlock Grid.Column="1" Text="Automatic Color" Margin="12,0,0,0" VerticalAlignment="Bottom" />
                                                                </Grid>
                                                            </Grid>
                                                            <DataTemplate.Triggers>
                                                                <DataTrigger 
                                                                    Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type ribbon:RibbonGalleryCategory}},Path=Header}" 
                                                                    Value="Automatic Color">
                                                                    <Setter TargetName="Rect" Property="Visibility" Value="Collapsed" />
                                                                    <Setter TargetName="AutomaticColorPane" Property="Visibility" Value="Visible" />
                                                                </DataTrigger>
                                                            </DataTemplate.Triggers>
                                                        </DataTemplate>
                                                    </ribbon:RibbonGallery.GalleryItemTemplate>
                                                </ribbon:RibbonGallery>
                                                <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.MoreColors}" />
                                            </ribbon:RibbonMenuItem>
                                        </ribbon:RibbonSplitButton>

                                        <ribbon:RibbonToggleButton DataContext="{x:Static data:WordModel.Strikethrough}" />
                                        <ribbon:RibbonToggleButton DataContext="{x:Static data:WordModel.Subscript}" />
                                        <ribbon:RibbonToggleButton DataContext="{x:Static data:WordModel.Superscript}" />

                                        <ribbon:RibbonControl x:Name="RC1">
                                            <ribbon:RibbonMenuButton x:Name="ChangeCaseMenuButton" DataContext="{x:Static data:WordModel.ChangeCase}">
                                                <ribbon:RibbonMenuButton.Resources>
                                                    <Style TargetType="{x:Type ribbon:RibbonMenuItem}" BasedOn="{StaticResource {x:Type ribbon:RibbonMenuItem}}">
                                                        <Setter Property="ImageSource" Value="{x:Null}" />
                                                        <Setter Property="QuickAccessToolBarImageSource" Value="{Binding SmallImage}" />
                                                    </Style>
                                                </ribbon:RibbonMenuButton.Resources>
                                                <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.SentenceCase}" />
                                                <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.Uppercase}" />
                                                <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.Lowercase}" />
                                                <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.CapitalizeEachWord}" />
                                                <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.ToggleCase}" />
                                            </ribbon:RibbonMenuButton>
                                        </ribbon:RibbonControl>

                                    </ribbon:RibbonControlGroup>

                                    <ContentControl x:Name="CC3" Focusable="False">
                                        <ribbon:RibbonControlGroup x:Name="RCG3">
                                            <ribbon:RibbonSplitButton 
                                                DataContext="{x:Static data:WordModel.TextHighlightColor}">
                                                <ribbon:RibbonGallery
                                                    DataContext="{x:Static data:WordModel.TextHighlightColorGallery}"
                                                    x:Name="TextHighlightColorGallery"
                                                    ScrollViewer.VerticalScrollBarVisibility="Hidden">
                                                    <ribbon:RibbonGallery.CategoryStyle>
                                                        <Style 
                                                            TargetType="{x:Type ribbon:RibbonGalleryCategory}" 
                                                            BasedOn="{StaticResource {x:Type ribbon:RibbonGalleryCategory}}">
                                                            <Setter Property="HeaderVisibility" Value="Collapsed" />
                                                            <Setter Property="MinColumnCount" Value="5" />
                                                            <Setter Property="MaxColumnCount" Value="5" />
                                                            <Style.Triggers>
                                                                <Trigger Property="Header" Value="No Color">
                                                                    <Setter Property="MinColumnCount" Value="1" />
                                                                    <Setter Property="MaxColumnCount" Value="1" />
                                                                    <Setter Property="IsSharedColumnSizeScope" Value="True" />
                                                                </Trigger>
                                                            </Style.Triggers>
                                                        </Style>
                                                    </ribbon:RibbonGallery.CategoryStyle>
                                                    <ribbon:RibbonGallery.GalleryItemTemplate>
                                                        <DataTemplate>
                                                            <Grid>
                                                                <Rectangle x:Name="Rect" Width="16" Height="16" Fill="{Binding}" />
                                                                <Grid x:Name="NoColorPane"
                                                                      Width="110"
                                                                      Visibility="Collapsed">
                                                                    <Grid.ColumnDefinitions>
                                                                        <ColumnDefinition Width="Auto" />
                                                                        <ColumnDefinition Width="*" />
                                                                    </Grid.ColumnDefinitions>
                                                                    <Rectangle Width="16" Height="16" StrokeThickness="1" Stroke="Orange" Fill="{Binding}" />
                                                                    <TextBlock Grid.Column="1" Text="No Color" Margin="12,0,0,0" VerticalAlignment="Bottom" />
                                                                </Grid>
                                                            </Grid>
                                                            <DataTemplate.Triggers>
                                                                <DataTrigger 
                                                                    Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type ribbon:RibbonGalleryCategory}},Path=Header}" 
                                                                    Value="No Color">
                                                                    <Setter TargetName="Rect" Property="Visibility" Value="Collapsed" />
                                                                    <Setter TargetName="NoColorPane" Property="Visibility" Value="Visible" />
                                                                </DataTrigger>
                                                            </DataTemplate.Triggers>
                                                        </DataTemplate>
                                                    </ribbon:RibbonGallery.GalleryItemTemplate>
                                                </ribbon:RibbonGallery>
                                                <ribbon:RibbonMenuItem 
                                                    DataContext="{x:Static data:WordModel.StopHighlighting}"
                                                    ImageSource="{x:Null}"
                                                    QuickAccessToolBarImageSource="{Binding SmallImage}" />
                                            </ribbon:RibbonSplitButton>
                                            
                                            <ribbon:RibbonSplitButton 
                                                DataContext="{x:Static data:WordModel.FontColor}">
                                                <ribbon:RibbonGallery
                                                    DataContext="{x:Static data:WordModel.FontColorGallery}"
                                                    x:Name="FontColorGallery"
                                                    ScrollViewer.VerticalScrollBarVisibility="Hidden">
                                                    <ribbon:RibbonGallery.CategoryStyle>
                                                        <Style 
                                                            TargetType="{x:Type ribbon:RibbonGalleryCategory}" 
                                                            BasedOn="{StaticResource {x:Type ribbon:RibbonGalleryCategory}}">
                                                            <Setter Property="MinColumnCount" Value="10" />
                                                            <Setter Property="MaxColumnCount" Value="10" />
                                                            <Style.Triggers>
                                                                <Trigger Property="Header" Value="Automatic Color">
                                                                    <Setter Property="HeaderVisibility" Value="Collapsed" />
                                                                    <Setter Property="MinColumnCount" Value="1" />
                                                                    <Setter Property="MaxColumnCount" Value="1" />
                                                                    <Setter Property="IsSharedColumnSizeScope" Value="True" />
                                                                </Trigger>
                                                            </Style.Triggers>
                                                        </Style>
                                                    </ribbon:RibbonGallery.CategoryStyle>
                                                    <ribbon:RibbonGallery.GalleryItemTemplate>
                                                        <DataTemplate>
                                                            <Grid>
                                                                <Rectangle x:Name="Rect" Width="16" Height="16" Fill="{Binding}" />
                                                                <Grid x:Name="AutomaticColorPane"
                                                                      Width="210"
                                                                      Visibility="Collapsed">
                                                                    <Grid.ColumnDefinitions>
                                                                        <ColumnDefinition Width="Auto" />
                                                                        <ColumnDefinition Width="*" />
                                                                    </Grid.ColumnDefinitions>
                                                                    <Rectangle Width="16" Height="16" StrokeThickness="1" Stroke="Orange" Fill="{Binding}"/>
                                                                    <TextBlock Grid.Column="1" Text="Automatic Color" Margin="12,0,0,0" VerticalAlignment="Bottom" />
                                                                </Grid>
                                                            </Grid>
                                                            <DataTemplate.Triggers>
                                                                <DataTrigger 
                                                                    Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type ribbon:RibbonGalleryCategory}},Path=Header}" 
                                                                    Value="Automatic Color">
                                                                    <Setter TargetName="Rect" Property="Visibility" Value="Collapsed" />
                                                                    <Setter TargetName="AutomaticColorPane" Property="Visibility" Value="Visible" />
                                                                </DataTrigger>
                                                            </DataTemplate.Triggers>
                                                        </DataTemplate>
                                                    </ribbon:RibbonGallery.GalleryItemTemplate>
                                                </ribbon:RibbonGallery>
                                                <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.MoreColors}" />
                                            </ribbon:RibbonSplitButton>
                                            
                                            <ribbon:RibbonControl x:Name="RC2" Visibility="Collapsed"/>
                                        </ribbon:RibbonControlGroup>
                                    </ContentControl>
                                    <ContentControl x:Name="CC4" Focusable="False"></ContentControl>
                                </StackPanel>
                                <StackPanel x:Name="SP3" 
                                            Grid.Row="2"
                                            VerticalAlignment="Center"
                                            Orientation="Horizontal">
                                    <ContentControl x:Name="CC5" Focusable="False"></ContentControl>
                                    <ContentControl x:Name="CC6" Focusable="False"></ContentControl>
                                </StackPanel>
                            </Grid>
                            <DataTemplate.Triggers>
                                <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=(ribbon:RibbonControlService.ControlSizeDefinition).ImageSize}" 
                                             Value="Small">
                                    <Setter TargetName="CC1" Property="Content" Value="{x:Null}"/>
                                    <Setter TargetName="CC6" Property="Content" Value="{Binding ElementName=RCG1}"/>
                                    <Setter TargetName="CC2" Property="Content" Value="{x:Null}"/>
                                    <Setter TargetName="CC4" Property="Content" Value="{Binding ElementName=RCG2}"/>
                                    <Setter TargetName="CC3" Property="Content" Value="{x:Null}"/>
                                    <Setter TargetName="CC5" Property="Content" Value="{Binding ElementName=RCG3}"/>
                                    <Setter TargetName="RC1" Property="Content" Value="{x:Null}"/>
                                    <Setter TargetName="RC1" Property="Visibility" Value="Collapsed"/>
                                    <Setter TargetName="RC2" Property="Content" Value="{Binding ElementName=ChangeCaseMenuButton}"/>
                                    <Setter TargetName="RC2" Property="Visibility" Value="Visible"/>
                                    <Setter TargetName="ThirdRow" Property="Height" Value="*"/>
                                    <Setter TargetName="SP2" Property="Margin" Value="0"/>
                                </DataTrigger>
                            </DataTemplate.Triggers>
                        </DataTemplate>
                        
                    </ribbon:RibbonGroup.Resources>

                    <ribbon:RibbonGroup.GroupSizeDefinitions>

                        <ribbon:RibbonGroupSizeDefinition>
                            <ribbon:RibbonControlSizeDefinition ImageSize="Large"/>
                        </ribbon:RibbonGroupSizeDefinition>
                        <ribbon:RibbonGroupSizeDefinition>
                            <ribbon:RibbonControlSizeDefinition ImageSize="Small"/>
                        </ribbon:RibbonGroupSizeDefinition>
                        <ribbon:RibbonGroupSizeDefinition IsCollapsed="True"/>

                    </ribbon:RibbonGroup.GroupSizeDefinitions>
                    
                    <ContentPresenter Height="{Binding ActualHeight, RelativeSource={RelativeSource AncestorType={x:Type Panel}}}" ContentTemplate="{StaticResource FontControlTemplate}"/>

                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup x:Name="Paragraph" DataContext="{x:Static data:WordModel.Paragraph}">
                    <ribbon:RibbonGroup.Resources>
                        <DataTemplate x:Key="ParagraphControlTemplate">
                            <Grid VerticalAlignment="Center">
                                <Grid.RowDefinitions>
                                    <RowDefinition/>
                                    <RowDefinition/>
                                    <RowDefinition x:Name="ThirdRow" Height="Auto"/>
                                </Grid.RowDefinitions>
                                
                                <StackPanel x:Name="SP1"
                                    Grid.Row="0"
                                    VerticalAlignment="Center"
                                    Orientation="Horizontal">
                                    
                                    <ribbon:RibbonControlGroup>
                                        <ribbon:RibbonSplitButton DataContext="{x:Static data:WordModel.Bullets}">
                                            <ribbon:RibbonGallery
                                                    DataContext="{x:Static data:WordModel.BulletsGallery}"
                                                    ScrollViewer.VerticalScrollBarVisibility="Visible">
                                                <ribbon:RibbonGallery.CategoryStyle>
                                                    <Style 
                                                            TargetType="{x:Type ribbon:RibbonGalleryCategory}" 
                                                            BasedOn="{StaticResource {x:Type ribbon:RibbonGalleryCategory}}">
                                                        <Setter Property="MinColumnCount" Value="6" />
                                                    </Style>
                                                </ribbon:RibbonGallery.CategoryStyle>
                                                <ribbon:RibbonGallery.GalleryItemTemplate>
                                                    <DataTemplate>
                                                        <Grid Width="40" Height="40">
                                                            <Border BorderThickness="1" BorderBrush="Gray">
                                                            </Border>
                                                            <Image HorizontalAlignment="Center" VerticalAlignment="Center"
                                                                   Width="32" Height="32" Source="{Binding}"/>
                                                        </Grid>
                                                    </DataTemplate>
                                                </ribbon:RibbonGallery.GalleryItemTemplate>
                                            </ribbon:RibbonGallery>
                                            
                                            <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.ChangeListLevel}">
                                                <ribbon:RibbonGallery DataContext="{x:Static data:WordModel.ChangeListLevelGallery}"
                                                                      ScrollViewer.VerticalScrollBarVisibility="Auto">
                                                    <ribbon:RibbonGallery.CategoryStyle>
                                                        <Style 
                                                            TargetType="{x:Type ribbon:RibbonGalleryCategory}" 
                                                            BasedOn="{StaticResource {x:Type ribbon:RibbonGalleryCategory}}">
                                                            <Setter Property="MinColumnCount" Value="1" />
                                                            <Setter Property="MaxColumnCount" Value="1" />
                                                            <Setter Property="HeaderVisibility" Value="Collapsed"/>
                                                        </Style>
                                                    </ribbon:RibbonGallery.CategoryStyle>
                                                    <ribbon:RibbonGallery.GalleryItemTemplate>
                                                        <DataTemplate>
                                                            <Grid Width="150" Height="20">
                                                                <Border BorderThickness="1" BorderBrush="Gray">
                                                                </Border>
                                                                <TextBlock Text="{Binding}"/>
                                                            </Grid>
                                                        </DataTemplate>
                                                    </ribbon:RibbonGallery.GalleryItemTemplate>
                                                </ribbon:RibbonGallery>
                                            </ribbon:RibbonMenuItem>
                                            <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.DefaultNewBullet}"
                                                                   ImageSource="{x:Null}"
                                                                   QuickAccessToolBarImageSource="{Binding SmallImage}">
                                            </ribbon:RibbonMenuItem>
                                        </ribbon:RibbonSplitButton>

                                        <ribbon:RibbonSplitButton DataContext="{x:Static data:WordModel.Numbering}">
                                            
                                            <ribbon:RibbonGallery
                                                    DataContext="{x:Static data:WordModel.NumberingGallery}"
                                                    ScrollViewer.VerticalScrollBarVisibility="Visible">
                                                <ribbon:RibbonGallery.CategoryStyle>
                                                    <Style TargetType="{x:Type ribbon:RibbonGalleryCategory}"
                                                           BasedOn="{StaticResource {x:Type ribbon:RibbonGalleryCategory}}">
                                                        <Setter Property="MinColumnCount" Value="3" />
                                                    </Style>
                                                </ribbon:RibbonGallery.CategoryStyle>
                                                <ribbon:RibbonGallery.GalleryItemTemplate>
                                                    <DataTemplate>
                                                        <Grid Width="60" Height="60">
                                                            <Border BorderThickness="1" BorderBrush="Gray">
                                                            </Border>
                                                            <Image HorizontalAlignment="Center" VerticalAlignment="Center"
                                                                   Width="48" Height="48" Source="{Binding}"/>
                                                        </Grid>
                                                    </DataTemplate>
                                                </ribbon:RibbonGallery.GalleryItemTemplate>
                                            </ribbon:RibbonGallery>
                                            
                                            <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.ChangeListLevel}">
                                                <ribbon:RibbonGallery DataContext="{x:Static data:WordModel.ChangeListLevelGallery}"
                                                                      ScrollViewer.VerticalScrollBarVisibility="Auto">
                                                    <ribbon:RibbonGallery.CategoryStyle>
                                                        <Style 
                                                            TargetType="{x:Type ribbon:RibbonGalleryCategory}" 
                                                            BasedOn="{StaticResource {x:Type ribbon:RibbonGalleryCategory}}">
                                                            <Setter Property="MinColumnCount" Value="1" />
                                                            <Setter Property="MaxColumnCount" Value="1" />
                                                            <Setter Property="HeaderVisibility" Value="Collapsed"/>
                                                        </Style>
                                                    </ribbon:RibbonGallery.CategoryStyle>
                                                    <ribbon:RibbonGallery.GalleryItemTemplate>
                                                        <DataTemplate>
                                                            <Grid Width="150" Height="20">
                                                                <Border BorderThickness="1" BorderBrush="Gray">
                                                                </Border>
                                                                <TextBlock Text="{Binding}"/>
                                                            </Grid>
                                                        </DataTemplate>
                                                    </ribbon:RibbonGallery.GalleryItemTemplate>
                                                </ribbon:RibbonGallery>
                                            </ribbon:RibbonMenuItem>
                                            <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.DefaultNewNumberFormat}"
                                                                   ImageSource="{x:Null}"
                                                                   QuickAccessToolBarImageSource="{Binding SmallImage}">
                                            </ribbon:RibbonMenuItem>
                                        </ribbon:RibbonSplitButton>

                                        <ribbon:RibbonMenuButton DataContext="{x:Static data:WordModel.MultilevelList}">
                                            
                                            <ribbon:RibbonGallery
                                                    DataContext="{x:Static data:WordModel.MultilevelListGallery}"
                                                    ScrollViewer.VerticalScrollBarVisibility="Visible">
                                                <ribbon:RibbonGallery.CategoryStyle>
                                                    <Style TargetType="{x:Type ribbon:RibbonGalleryCategory}"
                                                           BasedOn="{StaticResource {x:Type ribbon:RibbonGalleryCategory}}">
                                                        <Setter Property="MinColumnCount" Value="3" />
                                                    </Style>
                                                </ribbon:RibbonGallery.CategoryStyle>
                                                <ribbon:RibbonGallery.GalleryItemTemplate>
                                                    <DataTemplate>
                                                        <Grid Width="60" Height="60">
                                                            <Border BorderThickness="1" BorderBrush="Gray">
                                                            </Border>
                                                            <Image x:Name="image" HorizontalAlignment="Center" VerticalAlignment="Center"
                                                                   Width="48" Height="48" Source="{Binding}"/>
                                                            <Popup x:Name="popup"
                                                                   PlacementTarget="{Binding ElementName=image}"
                                                                   Placement="Center"
                                                                   IsOpen="False">
                                                                <Border Background="White"
                                                                        BorderBrush="Gray"
                                                                        BorderThickness="1"
                                                                        Padding="3">
                                                                    <Rectangle
                                                                        Height="{Binding ElementName=image, Path=ActualHeight}"
                                                                        Width="{Binding ElementName=image, Path=ActualWidth}">
                                                                        <Rectangle.LayoutTransform>
                                                                            <ScaleTransform ScaleX="1.5" ScaleY="1.5"/>
                                                                        </Rectangle.LayoutTransform>
                                                                        <Rectangle.Fill>
                                                                            <VisualBrush Visual="{Binding ElementName=image}"/>
                                                                        </Rectangle.Fill>
                                                                    </Rectangle>
                                                                </Border>
                                                            </Popup>
                                                        </Grid>
                                                        <DataTemplate.Triggers>
                                                            <Trigger Property="IsMouseOver" Value="True">
                                                                <Setter TargetName="popup" Property="IsOpen" Value="true"/>
                                                            </Trigger>
                                                        </DataTemplate.Triggers>
                                                    </DataTemplate>
                                                </ribbon:RibbonGallery.GalleryItemTemplate>
                                            </ribbon:RibbonGallery>
                                            
                                            <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.ChangeListLevel}">
                                                <ribbon:RibbonGallery DataContext="{x:Static data:WordModel.ChangeListLevelGallery}"
                                                                      ScrollViewer.VerticalScrollBarVisibility="Auto">
                                                    <ribbon:RibbonGallery.CategoryStyle>
                                                        <Style 
                                                            TargetType="{x:Type ribbon:RibbonGalleryCategory}" 
                                                            BasedOn="{StaticResource {x:Type ribbon:RibbonGalleryCategory}}">
                                                            <Setter Property="MinColumnCount" Value="1" />
                                                            <Setter Property="MaxColumnCount" Value="1" />
                                                            <Setter Property="HeaderVisibility" Value="Collapsed"/>
                                                        </Style>
                                                    </ribbon:RibbonGallery.CategoryStyle>
                                                    <ribbon:RibbonGallery.GalleryItemTemplate>
                                                        <DataTemplate>
                                                            <Grid Width="150" Height="20">
                                                                <Border BorderThickness="1" BorderBrush="Gray">
                                                                </Border>
                                                                <TextBlock Text="{Binding}"/>
                                                            </Grid>
                                                        </DataTemplate>
                                                    </ribbon:RibbonGallery.GalleryItemTemplate>
                                                </ribbon:RibbonGallery>
                                            </ribbon:RibbonMenuItem>
                                            <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.DefaultNewMultilevelList}"
                                                                   ImageSource="{x:Null}"
                                                                   QuickAccessToolBarImageSource="{Binding SmallImage}">
                                            </ribbon:RibbonMenuItem>
                                            <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.DefaultNewListStyle}"
                                                                   ImageSource="{x:Null}"
                                                                   QuickAccessToolBarImageSource="{Binding SmallImage}">
                                            </ribbon:RibbonMenuItem>
                                        </ribbon:RibbonMenuButton>
                                    </ribbon:RibbonControlGroup>

                                    <ribbon:RibbonControlGroup>
                                        <ribbon:RibbonButton DataContext="{x:Static data:WordModel.DecreaseIndent}">
                                        </ribbon:RibbonButton>

                                        <ribbon:RibbonButton DataContext="{x:Static data:WordModel.IncreaseIndent}">
                                        </ribbon:RibbonButton>
                                    </ribbon:RibbonControlGroup>
                                    
                                    <ContentControl x:Name="CC1" Focusable="False">
                                        <ribbon:RibbonControlGroup x:Name="RCG1">
                                            <ribbon:RibbonButton DataContext="{x:Static data:WordModel.Sort}">
                                            </ribbon:RibbonButton>
                                        </ribbon:RibbonControlGroup>
                                    </ContentControl>
                                    <ContentControl x:Name="CC2" Focusable="False">
                                        <ribbon:RibbonControlGroup x:Name="RCG2">
                                            <ribbon:RibbonToggleButton DataContext="{x:Static data:WordModel.ShowHide}">
                                            </ribbon:RibbonToggleButton>
                                        </ribbon:RibbonControlGroup>
                                    </ContentControl>
                                    
                                </StackPanel>
                                
                                <StackPanel x:Name="SP2"
                                    Grid.Row="1"
                                    Margin="0,5,0,0"
                                    VerticalAlignment="Center"
                                    Orientation="Horizontal">
                                    <ribbon:RibbonControlGroup>
                                        <ribbon:RibbonRadioButton DataContext="{x:Static data:WordModel.AlignTextLeft}">
                                        </ribbon:RibbonRadioButton>

                                        <ribbon:RibbonRadioButton DataContext="{x:Static data:WordModel.AlignTextCenter}">
                                        </ribbon:RibbonRadioButton>

                                        <ribbon:RibbonRadioButton DataContext="{x:Static data:WordModel.AlignTextRight}">
                                        </ribbon:RibbonRadioButton>

                                        <ribbon:RibbonRadioButton DataContext="{x:Static data:WordModel.Justify}">
                                        </ribbon:RibbonRadioButton>
                                    </ribbon:RibbonControlGroup>

                                    <ribbon:RibbonControlGroup>
                                        <ribbon:RibbonMenuButton DataContext="{x:Static data:WordModel.LineSpacing}">
                                            <ribbon:RibbonMenuButton.Resources>
                                                <Style TargetType="{x:Type ribbon:RibbonMenuItem}" BasedOn="{StaticResource {x:Type ribbon:RibbonMenuItem}}">
                                                    <Setter Property="ribbon:RibbonControlService.CanAddToQuickAccessToolBarDirectly" Value="False"/>
                                                    <Setter Property="CommandParameter" Value="{Binding}"/>
                                                </Style>
                                            </ribbon:RibbonMenuButton.Resources>
                                            <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.LineSpacingFirstValue}" />
                                            <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.LineSpacingSecondValue}" />
                                            <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.LineSpacingThirdValue}" />
                                            <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.LineSpacingFourthValue}" />
                                            <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.LineSpacingFifthValue}" />
                                            <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.LineSpacingSixthValue}" />
                                            <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.LineSpacingOptions}" />
                                            <ribbon:RibbonSeparator/>
                                            <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.AddSpaceBeforeParagraph}" />
                                            <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.RemoveSpaceAfterParagraph}" />
                                        </ribbon:RibbonMenuButton>
                                    </ribbon:RibbonControlGroup>

                                    <ContentControl x:Name="CC3" Focusable="False">
                                        <ribbon:RibbonControlGroup x:Name="RCG3">
                                            <ribbon:RibbonSplitButton DataContext="{x:Static data:WordModel.Shading}">
                                                <ribbon:RibbonGallery
                                                    DataContext="{x:Static data:WordModel.FontColorGallery}"
                                                    x:Name="FontColorGallery"
                                                    ScrollViewer.VerticalScrollBarVisibility="Hidden">
                                                    <ribbon:RibbonGallery.CategoryStyle>
                                                        <Style 
                                                            TargetType="{x:Type ribbon:RibbonGalleryCategory}" 
                                                            BasedOn="{StaticResource {x:Type ribbon:RibbonGalleryCategory}}">
                                                            <Setter Property="MinColumnCount" Value="10" />
                                                            <Setter Property="MaxColumnCount" Value="10" />
                                                            <Style.Triggers>
                                                                <Trigger Property="Header" Value="Automatic Color">
                                                                    <Setter Property="Visibility" Value="Collapsed"/>
                                                                    <Setter Property="HeaderVisibility" Value="Collapsed" />
                                                                </Trigger>
                                                            </Style.Triggers>
                                                        </Style>
                                                    </ribbon:RibbonGallery.CategoryStyle>
                                                    <ribbon:RibbonGallery.GalleryItemTemplate>
                                                        <DataTemplate>
                                                            <Grid>
                                                                <Rectangle x:Name="Rect" Width="16" Height="16" Fill="{Binding}" />
                                                            </Grid>
                                                            <DataTemplate.Triggers>
                                                                <DataTrigger 
                                                                    Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type ribbon:RibbonGalleryCategory}},Path=Header}" 
                                                                    Value="Automatic Color">
                                                                    <Setter TargetName="Rect" Property="Visibility" Value="Collapsed" />
                                                                </DataTrigger>
                                                            </DataTemplate.Triggers>
                                                        </DataTemplate>
                                                    </ribbon:RibbonGallery.GalleryItemTemplate>
                                                </ribbon:RibbonGallery>
                                                <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.MoreColors}" />
                                            </ribbon:RibbonSplitButton>

                                            <ribbon:RibbonSplitButton DataContext="{x:Static data:WordModel.Borders}">
                                                <ribbon:RibbonMenuButton.Resources>
                                                    <Style TargetType="{x:Type ribbon:RibbonMenuItem}" BasedOn="{StaticResource {x:Type ribbon:RibbonMenuItem}}">
                                                        <Setter Property="CommandParameter" Value="{Binding}"/>
                                                    </Style>
                                                </ribbon:RibbonMenuButton.Resources>
                                                <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.BottomBorder}" />
                                                <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.TopBorder}" />
                                                <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.LeftBorder}" />
                                                <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.RightBorder}" />
                                                <ribbon:RibbonSeparator/>
                                                <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.NoBorder}" />
                                                <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.AllBorders}" />
                                                <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.OutsideBorders}" />
                                                <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.InsideBorders}" />
                                                <ribbon:RibbonSeparator/>
                                                <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.InsideHorizontalBorder}" />
                                                <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.InsideVerticalBorder}" />
                                                <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.DiagonalDownBorder}" />
                                                <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.DiagonalUpBorder}" />
                                                <ribbon:RibbonSeparator/>
                                                <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.HorizontalLine}" />
                                                <ribbon:RibbonSeparator/>
                                                <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.DrawTable}" />
                                                <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.ViewGridLines}" />
                                                <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.BordersAndShading}" />
                                            </ribbon:RibbonSplitButton>
                                        </ribbon:RibbonControlGroup>
                                    </ContentControl>
                                </StackPanel>
                                
                                <StackPanel x:Name="SP3"
                                    Grid.Row="2"
                                    VerticalAlignment="Center"
                                    Orientation="Horizontal">
                                    <ContentControl x:Name="CC4" Focusable="False"></ContentControl>
                                    <ContentControl x:Name="CC5" Focusable="False"></ContentControl>
                                    <ContentControl x:Name="CC6" Focusable="False"></ContentControl>
                                </StackPanel>
                            </Grid>
                            <DataTemplate.Triggers>
                                <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=(ribbon:RibbonControlService.ControlSizeDefinition).ImageSize}" 
                                             Value="Small">
                                    <Setter TargetName="CC1" Property="Content" Value="{x:Null}"/>
                                    <Setter TargetName="CC5" Property="Content" Value="{Binding ElementName=RCG1}"/>
                                    <Setter TargetName="CC2" Property="Content" Value="{x:Null}"/>
                                    <Setter TargetName="CC6" Property="Content" Value="{Binding ElementName=RCG2}"/>
                                    <Setter TargetName="CC3" Property="Content" Value="{x:Null}"/>
                                    <Setter TargetName="CC4" Property="Content" Value="{Binding ElementName=RCG3}"/>
                                    <Setter TargetName="ThirdRow" Property="Height" Value="*"/>
                                    <Setter TargetName="SP2" Property="Margin" Value="0"/>
                                </DataTrigger>
                            </DataTemplate.Triggers>
                        </DataTemplate>
                    </ribbon:RibbonGroup.Resources>
                    
                    <ribbon:RibbonGroup.GroupSizeDefinitions>
                        <ribbon:RibbonGroupSizeDefinition>
                            <ribbon:RibbonControlSizeDefinition ImageSize="Large"/>
                        </ribbon:RibbonGroupSizeDefinition>
                        <ribbon:RibbonGroupSizeDefinition>
                            <ribbon:RibbonControlSizeDefinition ImageSize="Small"/>
                        </ribbon:RibbonGroupSizeDefinition>
                        <ribbon:RibbonGroupSizeDefinition IsCollapsed="True"/>
                    </ribbon:RibbonGroup.GroupSizeDefinitions>

                    <ContentPresenter Height="{Binding ActualHeight, RelativeSource={RelativeSource AncestorType={x:Type Panel}}}" ContentTemplate="{StaticResource ParagraphControlTemplate}"/>
                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup x:Name="Styles" DataContext="{x:Static data:WordModel.Styles}">
                    <ribbon:RibbonMenuButton DataContext="{x:Static data:WordModel.ChangeStyles}">
                        
                        <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.StylesSet}" >
                            <ribbon:RibbonGallery DataContext="{x:Static data:WordModel.StylesSetGalleryData}" MaxColumnCount="1" ColumnsStretchToFill="True">
                                <ribbon:RibbonGallery.Resources>
                                    
                                    <DataTemplate DataType="{x:Type data:StylesSet}">
                                        <StackPanel Orientation="Horizontal">
                                            <Path x:Name="CheckMark"
                                                  Visibility="Hidden"
                                                  Margin="4,0,6,0"
                                                  VerticalAlignment="Center"
                                                  HorizontalAlignment="Center"
                                                  Fill="{DynamicResource {x:Static SystemColors.MenuTextBrushKey}}"
                                                  FlowDirection="LeftToRight"
                                                  Data="M 0,5.1 L 1.7,5.2 L 3.4,7.1 L 8,0.4 L 9.2,0 L 3.3,10.8 Z" />
                                            <TextBlock Text="{Binding Label}" />
                                         </StackPanel>
                                        <DataTemplate.Triggers>
                                            <DataTrigger Binding="{Binding IsSelected}" Value="True">
                                                <Setter TargetName="CheckMark" Property="Visibility" Value="Visible" />
                                            </DataTrigger>
                                        </DataTemplate.Triggers>
                                    </DataTemplate>
                                    
                                </ribbon:RibbonGallery.Resources>
                                
                                <ribbon:RibbonGallery.GalleryItemStyle>
                                    <Style TargetType="ribbon:RibbonGalleryItem">
                                        <Setter Property="IsSelected" Value="{Binding IsSelected}" />
                                    </Style>
                                </ribbon:RibbonGallery.GalleryItemStyle>
                            </ribbon:RibbonGallery>
                            <ribbon:RibbonMenuItem Header="_Reset to Quick Styles from Template" KeyTip="R" ImageSource="{x:Null}"/>
                            <ribbon:RibbonMenuItem Header="Reset _Document Quick Styles" KeyTip="D" ImageSource="{x:Null}"/>
                            <ribbon:RibbonMenuItem Header="Save as _Quick Style Set..." KeyTip="Q" ImageSource="{x:Null}"/>
                        </ribbon:RibbonMenuItem>
                        
                        <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.Colors}" DropDownHeight="470">
                            <ribbon:RibbonGallery DataContext="{x:Static data:WordModel.StylesColorsGalleryData}" MaxColumnCount="1" ColumnsStretchToFill="True">
                                <ribbon:RibbonGallery.GalleryItemTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="Images\ColorPalette.png" />
                                            <Image Source="Images\ColorPalette.png" />
                                            <Image Source="Images\ColorPalette.png" />
                                            <TextBlock Margin="10,0,0,0" Text="{Binding}" />
                                        </StackPanel>
                                    </DataTemplate>
                                </ribbon:RibbonGallery.GalleryItemTemplate>
                            </ribbon:RibbonGallery>
                            <ribbon:RibbonMenuItem Header="_Create New Theme Colors" KeyTip="C" ImageSource="{x:Null}" />
                        </ribbon:RibbonMenuItem>
                        
                        <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.Fonts}" DropDownHeight="700">
                            <ribbon:RibbonGallery DataContext="{x:Static data:WordModel.StylesFontsGalleryData}" MaxColumnCount="1" ColumnsStretchToFill="True">
                                <ribbon:RibbonGallery.GalleryItemTemplate>
                                    <DataTemplate DataType="data:WordModel.ThemeFonts">
                                        <Grid>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="Auto" />
                                                <ColumnDefinition />
                                            </Grid.ColumnDefinitions>
                                            
                                            <Border BorderThickness="1" BorderBrush="Black">
                                                <Image Source="{Binding Field1}" />    
                                            </Border>
                                            <StackPanel Grid.Column="1" Margin="15,0,0,0">
                                                <TextBlock Text="{Binding Label}" FontFamily="Verdana" FontWeight="Bold" FontSize="10"/>
                                                <TextBlock Text="{Binding Field2}" FontFamily="{Binding Field2}" FontSize="15" />
                                                <TextBlock Text="{Binding Field3}" FontFamily="{Binding Field3}" FontSize="10"/>
                                            </StackPanel>
                                        </Grid>
                                    </DataTemplate>
                                </ribbon:RibbonGallery.GalleryItemTemplate>
                            </ribbon:RibbonGallery>
                            <ribbon:RibbonMenuItem Header="_Create New Theme Fonts" KeyTip="C" ImageSource="{x:Null}"/>
                        </ribbon:RibbonMenuItem>
                        
                        <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.ParagraphSpacing}">
                            <ribbon:RibbonGallery DataContext="{x:Static data:WordModel.StylesParagraphGalleryData}" 
                                                  ItemsSource="{Binding CategoryDataCollection}"
                                                  ColumnsStretchToFill="True"
                                                  ScrollViewer.VerticalScrollBarVisibility="Hidden">
                                <ribbon:RibbonGallery.ItemTemplate>
                                    <HierarchicalDataTemplate ItemsSource="{Binding GalleryItemDataCollection}">
                                        <Border Background="LightGray">
                                            <TextBlock Text="{Binding}" FontWeight="Bold" />
                                        </Border>
                                        <HierarchicalDataTemplate.ItemTemplate>
                                            <DataTemplate>
                                                <StackPanel Orientation="Horizontal">
                                                    <Image Source="Images\Paragraph_32x32.png" />
                                                    <TextBlock Margin="10,0,0,0" Text="{Binding}" />
                                                </StackPanel>
                                            </DataTemplate>
                                        </HierarchicalDataTemplate.ItemTemplate>
                                    </HierarchicalDataTemplate>
                                </ribbon:RibbonGallery.ItemTemplate>
                            </ribbon:RibbonGallery>
                            <ribbon:RibbonMenuItem Header="Custom Paragraph Spacing..." KeyTip="C"  ImageSource="{x:Null}"/>
                        </ribbon:RibbonMenuItem>
                        <ribbon:RibbonSeparator/>
                        <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.SetAsDefault}" />
                    </ribbon:RibbonMenuButton>

                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup x:Name="Editing" DataContext="{x:Static data:WordModel.Editing}">
                    <ribbon:RibbonSplitButton DataContext="{x:Static data:WordModel.Find}">
                        <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.FindMenuItem}" />
                        <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.AdvancedFind}" />
                        <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.GoTo}" />
                    </ribbon:RibbonSplitButton>
                    <ribbon:RibbonButton DataContext="{x:Static data:WordModel.Replace}" />
                    <ribbon:RibbonMenuButton DataContext="{x:Static data:WordModel.Select}">
                        <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.SelectAll}" />
                        <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.SelectObjects}" />
                        <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.SelectAllText}" />
                        <ribbon:RibbonMenuItem DataContext="{x:Static data:WordModel.SelectionPane}" />
                    </ribbon:RibbonMenuButton>
                </ribbon:RibbonGroup>


            </ribbon:RibbonTab>

            <ribbon:RibbonTab Header="Insert" KeyTip="N">

                <ribbon:RibbonGroup Header="Pages">

                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup Header="Tables">
                    <ribbon:RibbonMenuButton DataContext="{x:Static data:WordModel.Table}">
                        <ribbon:RibbonGallery DataContext="{x:Static data:WordModel.TableGallery}" MinColumnCount="10" ScrollViewer.VerticalScrollBarVisibility="Hidden">
                            <ribbon:RibbonGallery.GalleryItemTemplate>
                                <DataTemplate>
                                    <Border BorderBrush="Black" BorderThickness="1" Height="10" Width="10" />
                                </DataTemplate>
                            </ribbon:RibbonGallery.GalleryItemTemplate>
                        </ribbon:RibbonGallery>
                    </ribbon:RibbonMenuButton>
                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup Header="Illustrations">

                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup Header="Links">

                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup Header="Header &amp; Footer">

                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup Header="Text">

                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup Header="Symbols">

                </ribbon:RibbonGroup>

            </ribbon:RibbonTab>
            
            <ribbon:RibbonTab DataContext="{x:Static data:WordModel.DesignTab}" Style="{StaticResource ContextualTabStyle}" KeyTip="JT">
                <ribbon:RibbonGroup Header="Table Style Options">
                    <ribbon:RibbonCheckBox DataContext="{x:Static data:WordModel.HeaderRow}" Height="22" />
                    <ribbon:RibbonCheckBox DataContext="{x:Static data:WordModel.TotalRow}"  Height="22"  />
                    <ribbon:RibbonCheckBox DataContext="{x:Static data:WordModel.BandedRows}"  Height="22"  />
                    <ribbon:RibbonCheckBox DataContext="{x:Static data:WordModel.FirstColumn}"  Height="22" />
                    <ribbon:RibbonCheckBox DataContext="{x:Static data:WordModel.LastColumn}"  Height="22"  />
                    <ribbon:RibbonCheckBox DataContext="{x:Static data:WordModel.BandedColumns}"  Height="22" />
                </ribbon:RibbonGroup>
            </ribbon:RibbonTab>

            <ribbon:RibbonTab DataContext="{x:Static data:WordModel.LayoutTab}" Style="{StaticResource ContextualTabStyle}" KeyTip="JL">
                
            </ribbon:RibbonTab>
            
            <ribbon:RibbonTab Header="Page Layout" KeyTip="P">

                <ribbon:RibbonGroup Header="Themes">

                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup Header="Page Setup">

                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup Header="Page Background">

                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup Header="Paragraph" KeyTip="ZG">
                    <ribbon:RibbonGroup.Resources>
                        <!-- Vertical Separator-->                        
                        <Style TargetType="{x:Type ribbon:RibbonSeparator}" x:Key="RibbonSeparatorStyleKey">
                            <Setter Property="LayoutTransform">
                                <Setter.Value>
                                    <RotateTransform Angle="90"/>                                                                            
                                </Setter.Value>
                            </Setter>
                        </Style>

                        <!-- Image -->
                        <Style TargetType="{x:Type Image}" x:Key="ImageStyle16Key">
                            <Setter Property="Width" Value="16"/>
                            <Setter Property="Height" Value="16"/>
                            <Setter Property="VerticalAlignment" Value="Center"/>
                            <Setter Property="HorizontalAlignment" Value="Center"/>
                            <Setter Property="Margin" Value="1"/>
                            <Setter Property="RenderOptions.BitmapScalingMode" Value="NearestNeighbor"/>
                        </Style>                                                         
                    </ribbon:RibbonGroup.Resources>
                    <ribbon:RibbonGroup.GroupSizeDefinitions>
                        <ribbon:RibbonGroupTemplateSizeDefinition>                            
                            <DataTemplate>
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition/>
                                        <RowDefinition/>
                                        <RowDefinition/>
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition/>
                                        <ColumnDefinition/>
                                        <ColumnDefinition/>
                                    </Grid.ColumnDefinitions>
                                    <!-- Indent -->
                                    <TextBlock Grid.Row="0" Grid.Column="0" Text="Indent" HorizontalAlignment="Left"/>
                                    <Grid Grid.Row="1" Grid.Column="0" Name="LeftIndentGrid">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition/>
                                            <ColumnDefinition Width="35"/>
                                            <ColumnDefinition/>
                                        </Grid.ColumnDefinitions>
                                        <Image Grid.Column="0" Source="Images\DecreaseIndent_16X16.png" Style="{StaticResource ImageStyle16Key}"/>
                                        <TextBlock Grid.Column="1" Text="Left:" HorizontalAlignment="Left" TextAlignment="Left" Margin="3,0,0,0"/>
                                        <ribbon:RibbonTextBox Grid.Column="2"  KeyTip="IL"/>
                                    </Grid>
                                    <Grid Grid.Row="2" Grid.Column="0" Name="RightIndentGrid">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition/>
                                            <ColumnDefinition Width="35"/>
                                            <ColumnDefinition/>
                                        </Grid.ColumnDefinitions>
                                        <Image Grid.Column="0" Source="Images\IncreaseIndent_16X16.png" Style="{StaticResource ImageStyle16Key}"/>
                                        <TextBlock Grid.Column="1" Text="Right:" HorizontalAlignment="Left" TextAlignment="Left" Margin="3,0,0,0"/>
                                        <ribbon:RibbonTextBox Grid.Column="2"  KeyTip="IR"/>
                                    </Grid>

                                    <!-- Separator -->
                                    <ribbon:RibbonSeparator Grid.RowSpan="3" Grid.Column="1" Margin="1,5,5,0" Style="{StaticResource RibbonSeparatorStyleKey}"/>

                                <!-- Spacing -->
                                    <TextBlock Grid.Row="0" Grid.Column="2" Text="Spacing" HorizontalAlignment="Left"/>
                                    <Grid Grid.Row="1" Grid.Column="2" Name="BeforeSpacingGrid">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition/>
                                            <ColumnDefinition Width="40"/>
                                            <ColumnDefinition/>
                                        </Grid.ColumnDefinitions>                                            
                                        <Image Grid.Column="0" Source="Images\LineSpacing_16X16.png" Style="{StaticResource ImageStyle16Key}"/>
                                        <TextBlock Grid.Column="1" Text="Before:" TextAlignment="Left" HorizontalAlignment="Left" Margin="3,0,0,0"/>
                                        <ribbon:RibbonTextBox Grid.Column="2"  KeyTip="SB"/>
                                    </Grid>
                                    <Grid Grid.Row="2" Grid.Column="2" Name="AfterSpacingGrid">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition/>
                                            <ColumnDefinition Width="40"/>
                                            <ColumnDefinition/>
                                        </Grid.ColumnDefinitions>
                                        <Image Grid.Column="0" Source="Images\LineSpacing_16X16.png" Style="{StaticResource ImageStyle16Key}"/>
                                        <TextBlock Grid.Column="1" Text="After:" TextAlignment="Left" HorizontalAlignment="Left" Margin="3,0,0,0"/>
                                        <ribbon:RibbonTextBox Grid.Column="2"  KeyTip="SA"/>
                                    </Grid>
                                </Grid>
                            </DataTemplate>                            
                        </ribbon:RibbonGroupTemplateSizeDefinition>
                        <ribbon:RibbonGroupTemplateSizeDefinition>                            
                            <DataTemplate>
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition/>
                                        <RowDefinition/>
                                        <RowDefinition/>
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition/>
                                        <ColumnDefinition/>
                                        <ColumnDefinition/>
                                    </Grid.ColumnDefinitions>
                                    
                                    <!-- Indent -->
                                    <TextBlock Grid.Row="0" Grid.Column="0" Text="Indent" HorizontalAlignment="Left"/>
                                    <Grid Grid.Row="1" Grid.Column="0">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition/>
                                            <ColumnDefinition/>
                                        </Grid.ColumnDefinitions>
                                        <Image Grid.Column="0" Source="Images\DecreaseIndent_16X16.png" Style="{StaticResource ImageStyle16Key}"/>
                                        <ribbon:RibbonTextBox Grid.Column="2"  KeyTip="IL"/>
                                    </Grid>
                                    <Grid Grid.Row="2" Grid.Column="0">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition/>
                                            <ColumnDefinition/>
                                        </Grid.ColumnDefinitions>
                                        <Image Grid.Column="0" Source="Images\IncreaseIndent_16X16.png" Style="{StaticResource ImageStyle16Key}"/>
                                        <ribbon:RibbonTextBox Grid.Column="2"  KeyTip="IR"/>
                                    </Grid>

                                    <!-- Separator-->
                                    <ribbon:RibbonSeparator Grid.RowSpan="3" Grid.Column="1" Margin="1,5,5,0" Style="{StaticResource RibbonSeparatorStyleKey}"/>

                                    <!-- Spacing-->
                                    <TextBlock Grid.Row="0" Grid.Column="2" Text="Spacing" HorizontalAlignment="Left"/>
                                    <Grid Grid.Row="1" Grid.Column="2">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition/>
                                            <ColumnDefinition/>
                                        </Grid.ColumnDefinitions>
                                        <Image Grid.Column="0" Source="Images\LineSpacing_16X16.png" Style="{StaticResource ImageStyle16Key}"/>
                                        <ribbon:RibbonTextBox Grid.Column="2" KeyTip="SB"/>
                                    </Grid>
                                    <Grid Grid.Row="2" Grid.Column="2">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition/>
                                            <ColumnDefinition/>
                                        </Grid.ColumnDefinitions>
                                        <Image Grid.Column="0" Source="Images\LineSpacing_16X16.png" Style="{StaticResource ImageStyle16Key}"/>
                                        <ribbon:RibbonTextBox Grid.Column="2" KeyTip="SA"/>
                                    </Grid>
                                </Grid>
                            </DataTemplate>                            
                        </ribbon:RibbonGroupTemplateSizeDefinition>
                        <ribbon:RibbonGroupTemplateSizeDefinition IsCollapsed="True"/>
                    </ribbon:RibbonGroup.GroupSizeDefinitions>
                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup Header="Arrange">

                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup Header="Table of Contents">

                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup Header="Footnotes">

                </ribbon:RibbonGroup>

            </ribbon:RibbonTab>

            <ribbon:RibbonTab Header="References" KeyTip="S">

                <ribbon:RibbonGroup Header="Citations and Bibliography">

                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup Header="Captions">

                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup Header="Index">

                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup Header="Table of Authorities">

                </ribbon:RibbonGroup>

            </ribbon:RibbonTab>

            <ribbon:RibbonTab Header="Mailings" KeyTip="M">

                <ribbon:RibbonGroup Header="Create">

                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup Header="Start Main Merge">

                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup Header="Write &amp; Insert Fields">

                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup Header="Preview Results">

                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup Header="Finish">

                </ribbon:RibbonGroup>

            </ribbon:RibbonTab>

            <ribbon:RibbonTab Header="Review" KeyTip="R">

                <ribbon:RibbonGroup Header="Proofing">

                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup Header="Language">

                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup Header="Comments">

                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup Header="Tracking">

                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup Header="Changes">

                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup Header="Compare">

                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup Header="Protect">

                </ribbon:RibbonGroup>

            </ribbon:RibbonTab>

            <ribbon:RibbonTab Header="View" KeyTip="W">

                <ribbon:RibbonGroup Header="Document Views">

                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup Header="Show">

                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup Header="Zoom">

                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup Header="Window">

                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup Header="Macros">

                </ribbon:RibbonGroup>

            </ribbon:RibbonTab>


            <ribbon:Ribbon.ContextualTabGroups>
                <ribbon:RibbonContextualTabGroup Background="#FF64CD30" DataContext="{x:Static data:WordModel.TableTabGroup}" />
            </ribbon:Ribbon.ContextualTabGroups>

        </ribbon:Ribbon>

        <RichTextBox Grid.Row="1" x:Name="RTB" SelectionChanged="RTB_SelectionChanged">
#ifdef Net40
            <RichTextBox.Resources>
                <Style TargetType="{x:Type ScrollViewer}">
                    <Setter Property="ContentTemplate">
                        <Setter.Value>
                            <DataTemplate>
                                <Border Background="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}},Path=Background}" 
                                        RenderOptions.ClearTypeHint="Enabled">
                                    <ContentPresenter Content="{Binding}" />
                                </Border>
                            </DataTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </RichTextBox.Resources>
#endif
            <FlowDocument x:Name="flowDoc">
                <Paragraph>
                    <Run>Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, 'and what is the use of a book,' thought Alice 'without pictures or conversation?'</Run>
                </Paragraph>
                <Paragraph>
                    <Run>So she was considering in her own mind (as well as she could, for the hot day made her feel very sleepy and stupid), whether the pleasure of making a daisy-chain would be worth the trouble of getting up and picking the daisies, when suddenly a White Rabbit with pink eyes ran close by her.</Run>
                </Paragraph>
            </FlowDocument>
        </RichTextBox>
    </Grid>
</UserControl>
